package com.wl.mr.sort;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SortMapper extends Mapper<LongWritable, Text,SortBean, NullWritable> {
    SortBean k = new SortBean();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] fields = value.toString().split("\t");
        k.setSelfDuration(Long.parseLong(fields[4]));
        k.setThirDuration(Long.parseLong(fields[5]));
        k.setId(fields[1]);
        k.setSumDuration(Long.parseLong(fields[4]) + Long.parseLong(fields[5]));

        context.write(k,NullWritable.get());
    }
}
